package service;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import common.kit.PageSql;
import enums.UnbindStatus;

public class UnbindService extends BaseService {

	public Page<Record> getPage(Kv kv , Integer pageNumber , Integer pageSize) {
		String select = " tu.id,tu.createTime,ts.name,ts.contacts,ts.mobile,tc.name AS companyName,tc.contacts AS companyContacts,tc.mobile AS companyMobile,tu.status " ;
	    PageSql pageSql = PageSql.bySelect( kv , select ) ;
	    pageSql.from(" t_unbind tu ") ;
	    pageSql.join(" t_servicer ts " , " ts.id = tu.servicerId ") ;
	    pageSql.join(" t_company tc " , " tc.id = tu.companyId ") ;
		pageSql.setEqualCondition("tu.status") ; //状态	 
		pageSql.setLikeCondition("ts.name") ; //运维公司	 
		pageSql.setLikeCondition("tc.name") ; //企业名称	 
	    pageSql.orderBy(" tu.createTime DESC ");
		Page<Record> page = pageSql.paginate( pageNumber , pageSize) ;
		for (Record record : page.getList()) {
			record.set("statusStr", UnbindStatus.getTitleByValue(record , "status"));
		}
	    return page ;
	}
}
